﻿#include "ObjType.h"
#include "BallBuilder.h"
#include "OtherSingleBuilder.h"
#include "MultipleBuilder.h"
#include "SingleBuilder.h"
#include "WallBuilder.h"
#include "SwampBuilder.h"

QHash<QString, PerformerBuilder*> * ObjType::_type = new QHash<QString, PerformerBuilder*>();
ParameterBuilder * ObjType::_para = new ParameterBuilder();
ObjType * ObjType::_obj_type = new ObjType();

ObjType::ObjType()
{
    _type->insert("Ball", new BallBuilder());
    _type->insert("OtherSingle", new OtherSingleBuilder());
    _type->insert("Multiple", new MultipleBuilder());
    _type->insert("Single", new SingleBuilder());
    _type->insert("Wall", new WallBuilder());
    _type->insert("Swamp", new SwampBuilder());
}

ObjType::~ObjType()
{

}

ParameterBuilder * ObjType::getPara()
{
    return ObjType::_para;
}

PerformerBuilder *ObjType::getType(const QString &type)
{
    QHash<QString, PerformerBuilder*>::iterator iter = ObjType::_type->find(type);
    if(iter != ObjType::_type->end())
    {
        return *iter;
    }
    else
    {
        return (*ObjType::_type)["OtherSingle"];
    }
}
